package com.lxy.cloud.mqtt.client.service.impl;

import com.lxy.cloud.mqtt.client.constant.SystemConstant;
import com.lxy.cloud.mqtt.client.model.vo.A2FileInfoVO;
import com.lxy.cloud.mqtt.client.model.vo.BaseCommandVO;
import com.lxy.cloud.mqtt.client.service.CommandService;
import com.lxy.cloud.mqtt.client.service.SendMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.MessageFormat;

/**
 * @Author: lxy
 * @Date: 2020/9/8 10:07
 * @Desc: 处理往车端发送A2文件下载信息
 */
@Service
public class CommandServiceImpl implements CommandService {

    @Autowired
    private SendMsgService sendMsgService;

    @Override
    public void sendA2FileInfo() {
        A2FileInfoVO info = new A2FileInfoVO();
        info.setVersionNewest("1");
        info.setA2FileName("1");
        info.setA2FileUrlLeng(0L);
        info.setA2FileUrl("1");
        //按vin码发送
        String topic = MessageFormat.format(SystemConstant.TOPIC_COMMAND, "123456");
        BaseCommandVO param = BaseCommandVO.builder()
                .topic(topic)
                .method("FOTA_ A2VersionNewReq")
                .data(info).build();
        sendMsgService.sendMsg(param);
    }
}
